package cn.lingyangwl.agile.common.feign;

import cn.lingyangwl.agile.common.feign.interceptor.FeignCommonRequestInterceptor;
import cn.lingyangwl.agile.common.feign.interceptor.FeignOauth2RequestInterceptor;
import feign.RequestInterceptor;
import feign.codec.ErrorDecoder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author shenguangyang
 */
@Configuration
@ConditionalOnClass({ FeignAutoConfiguration.class})
public class FeignMainConfig {

    @Bean
    public RequestInterceptor feignCommonRequestInterceptor() {
        return new FeignCommonRequestInterceptor();
    }

    @Bean
    public ErrorDecoder errorDecoder() {
        return new MyErrorDecoder();
    }

    @Bean
    public RequestInterceptor requestInterceptor() {
        return new FeignOauth2RequestInterceptor();
    }
}
